//
// Created by MikeChen on 2025/3/26.
//


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    //float 4*8=32位 符号1位 指数8位 尾数23位
    // （+-）1.17549-38~（+-）3.40282e+38
    //double
    //（+-）2.22507e-308~（+-）1.79769+308
    printf("float = %d\n", sizeof(float));//4
    printf("double =  %d\n", sizeof(double));//8
    printf("long double =  %d\n", sizeof(long double));//16
    float val1 = 3.1415926927328;
    double val2 = 3.1415926927328;
    printf("float val1 = %f\n",val1);
    printf("float val1 = %0.13f\n",val1);//精度丢失float val1 = 3.1415927410126
    printf("double val1 = %lf\n",val2);
    printf("double val1 = %0.13lf\n",val2);//double val1 = 3.1415926927328

    //隐式转换：
    //1.小数给整数赋值，只会保留整数部分，小数部分直接舍弃，没有四舍五入
    int val3;
    val3 = 6.88;
    printf("int val3 = %d\n",val3);//int val3 = 6
    //2.double类型的数据存储到float类型的变量中，可能会丢失精度

    //3.整数给字符类型赋值和字符给整数赋值，只要不超出范围，会按照ASCII码表上的对应字符赋值
    char val4 = 35;
    int val5 = 'a';
    printf("char val4 = %c\n",val4);//char val4 = #
    printf("int val5 = %d\n",val5);//int val5 = 97

    //显式转换：强转
    printf("%d\n",(int)123.456);//123
    printf("%c\n",(char)36);//$
    system("read -rsp $'Press enter to continue...\\n'");
    return EXIT_SUCCESS;
}